package com.gitee.wsl.time.flow

import com.gitee.wsl.time.Year
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.filter
import kotlinx.datetime.DayOfWeek
import kotlinx.datetime.LocalDateTime
import kotlinx.datetime.Month
import kotlinx.datetime.isoDayNumber
import kotlinx.datetime.number


@Suppress("NOTHING_TO_INLINE")
inline fun Flow<LocalDateTime>.filterSeconds(vararg seconds: Int) = filter { it.second in seconds }

@Suppress("NOTHING_TO_INLINE")
inline fun Flow<LocalDateTime>.filterMinutes(vararg minutes: Int) = filter { it.minute in minutes }

@Suppress("NOTHING_TO_INLINE")
inline fun Flow<LocalDateTime>.filterHours(vararg hours: Int) = filter { it.hour in hours }

@Suppress("NOTHING_TO_INLINE")
inline fun Flow<LocalDateTime>.filterDaysOfMonths(vararg daysOfMonths: Int) = filter { it.dayOfMonth in daysOfMonths }

@Suppress("NOTHING_TO_INLINE")
inline fun Flow<LocalDateTime>.filterMonths(vararg months: Month) = filter { it.month in months }
@Suppress("NOTHING_TO_INLINE")
inline fun Flow<LocalDateTime>.filterMonths0(vararg months: Int) = filter { it.month.ordinal in months }
@Suppress("NOTHING_TO_INLINE")
inline fun Flow<LocalDateTime>.filterMonths1(vararg months: Int) = filter { it.month.number in months }

@Suppress("NOTHING_TO_INLINE")
inline fun Flow<LocalDateTime>.filterYears(year: Year) = filter { it.year == year.value }
@Suppress("NOTHING_TO_INLINE")
inline fun Flow<LocalDateTime>.filterYears(vararg years: Int) = filter { it.year in years }

@Suppress("NOTHING_TO_INLINE")
inline fun Flow<LocalDateTime>.filterWeekDays(vararg weekDays: DayOfWeek) = filter { it.dayOfWeek in weekDays }
@Suppress("NOTHING_TO_INLINE")
inline fun Flow<LocalDateTime>.filterWeekDays(vararg weekDays: Int) = filter { it.dayOfWeek.isoDayNumber in weekDays }
